package top.hcode.hoj.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.dto.coll.AdmQueryCollQuestionOptionDTO;
import top.hcode.hoj.pojo.dto.coll.AdmSaveCollQuestionOptionsDTO;
import top.hcode.hoj.pojo.entity.coll.CollQuestionOption;
import top.hcode.hoj.service.admin.AdminCollQuestionOptionService;

import java.util.List;

/**
 * @author orangej
 * @since 2025-02-09
 */
@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class AdminCollQuestionOptionController {

    private final AdminCollQuestionOptionService questionOptionService;

    @GetMapping("/admin/coll-question-option/list")
    public CommonResult<IPage<CollQuestionOption>> getCollQuestionOptionList(AdmQueryCollQuestionOptionDTO form) {
        return CommonResult.successResponse(questionOptionService.getCollQuestionOptionList(form));
    }

    @ApiOperation(value="保存选择题选项列表")
    @PostMapping("/admin/coll-question-option/save")
    public CommonResult<List<CollQuestionOption>> saveCollQuestionOption(@RequestBody AdmSaveCollQuestionOptionsDTO form) {
        return CommonResult.successResponse(questionOptionService.saveCollQuestionOption(form));
    }

}
